<?php
/*
*/

!defined('IN_MOOPHP') && exit('Access Denied');

class array2xml {   
 var $xml;   
 function array2xml($array,$encoding='GB2312') {   
 $this->xml='<?xml version="1.0" encoding="'.$encoding.'"?>';   
 $this->xml.=$this->_array2xml($array);   
 }   
  
 function getXml() {   
 return $this->xml;   
 }   
  
 function _array2xml($array) {   
 $xml="";  
  foreach($array as $key=>$val) {   
   $num=is_numeric($key);   
   if(!$num) $xml.="<$key>";   
   
   if(is_array($val)){  
   $xml.=$this->_array2xml($val);  
   }  
   else{  
   $xml.=$val;   
   }  
   
   list($key,)=explode(' ',$key);   
   if(!$num) $xml.="</$key>";   
  }   
 return $xml;   
 }   
}
